package top.zhangjianyong.tools.service.mybatis.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.zhangjianyong.tools.entity.Config;
import top.zhangjianyong.tools.mapper.ConfigMapper;
import top.zhangjianyong.tools.service.mybatis.IConfigService;

/**
 * @author zhangjianyong
 * @since 2025/5/7 11:56
 */
@Service
public class IConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements IConfigService {
    @Override
    public Config getByCode(String code) {
        return lambdaQuery()
                .eq(Config::getConfigCode, code)
                .eq(Config::getDelFlag, 0)
                .one();
    }

    @Override
    public boolean updateConfig(String code, String value) {
        return lambdaUpdate()
                .eq(Config::getConfigCode, code)
                .set(Config::getConfigValue, value)
                .update();
    }

}
